/*************************************************************************
 *                                                                       *
 * This file is part of the FreeMAPs distribution.  For full copyright   *
 * information, see COPYRIGHT and COPYING.LESSER.                        *
 *                                                                       *
 * Author:           sqbang                                              *
 * Email:            sqbang@ustc.edu                                     *
 * Date:             2013.12.10                                          *
 *                                                                       *
 *************************************************************************/

namespace FreeMAPs
{

template<class TYPE>
void
MathUtilities<TYPE>::set_vector_to_signaling_NaN(
    std::vector<TYPE>& vector)
{
    for (int i = 0; i < static_cast<int>(vector.size()); i++)
    {
        vector[i] = get_signaling_NaN();
    }
}


template<class TYPE>
void
MathUtilities<TYPE>::set_array_to_signaling_NaN(
    TYPE* array,
    int n)
{
    for (int i = 0; i < n; i++)
    {
        array[i] = get_signaling_NaN();
    }
}


template<class TYPE>
void
MathUtilities<TYPE>::set_vector_to_max(
    std::vector<TYPE>& vector)
{
    for (int i = 0; i < static_cast<int>(vector.size()); i++)
    {
        vector[i] = get_max();
    }
}


template<class TYPE>
void
MathUtilities<TYPE>::set_array_to_max(
    TYPE* array,
    int n)
{
    for (int i = 0; i < n; i++)
    {
        array[i] = get_max();
    }
}


template<class TYPE>
void
MathUtilities<TYPE>::set_vector_to_min(
    std::vector<TYPE>& vector)
{
    for (int i = 0; i < static_cast<int>(vector.size()); i++)
    {
        vector[i] = get_min();
    }
}


template<class TYPE>
void
MathUtilities<TYPE>::set_array_to_min(
    TYPE* array,
    int n)
{
    for (int i = 0; i < n; i++)
    {
        array[i] = get_min();
    }
}


template<class TYPE>
void
MathUtilities<TYPE>::set_vector_to_epsilon(
    std::vector<TYPE>& vector)
{
    for (int i = 0; i < static_cast<int>(vector.size()); i++)
    {
        vector[i] = get_epsilon();
    }
}


template<class TYPE>
void
MathUtilities<TYPE>::set_array_to_epsilon(
    TYPE* array,
    int n)
{
    for (int i = 0; i < n; i++)
    {
        array[i] = get_epsilon();
    }
}


template<class TYPE>
TYPE
MathUtilities<TYPE>::get_zero()
{
    return s_zero;
}


template<class TYPE>
TYPE
MathUtilities<TYPE>::get_one()
{
    return s_one;
}


template<class TYPE>
TYPE
MathUtilities<TYPE>::get_signaling_NaN()
{
    return std::numeric_limits<TYPE>::signaling_NaN();
}


template<class TYPE>
TYPE
MathUtilities<TYPE>::get_max()
{
    return std::numeric_limits<TYPE>::max();
}


template<class TYPE>
TYPE
MathUtilities<TYPE>::get_min()
{
    return std::numeric_limits<TYPE>::min();
}


template<class TYPE>
TYPE
MathUtilities<TYPE>::get_epsilon()
{
    return std::numeric_limits<TYPE>::epsilon();
}


template<class TYPE>
bool
MathUtilities<TYPE>::is_NaN(
    const TYPE& value)
{
    NULL_USE(value);
    return false;
}


template<class TYPE>
bool
MathUtilities<TYPE>::equal_eps(
    const TYPE& a,
    const TYPE& b)
{
    return a == b;
}


template<class TYPE>
TYPE
MathUtilities<TYPE>::min(
    TYPE a,
    TYPE b)
{
    return a < b ? a : b;
}


template<class TYPE>
TYPE
MathUtilities<TYPE>::max(
    TYPE a,
    TYPE b)
{
    return a > b ? a : b;
}


template<class TYPE>
TYPE
MathUtilities<TYPE>::abs(
    TYPE value)
{
    return value;
}


template<class TYPE>
TYPE
MathUtilities<TYPE>::round(
    TYPE x)
{
    return x;
}

}
